<?php
require_once "managerSession.php";
if($manager["role"]!="超级管理员"){
    echo "你没有权限";
    exit;
}
$Item="奖品管理";
$arr=$core->GetAllPrizes();
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>娱乐会所吧台管理系统</title>
    <?php include_once "link.php"; ?>
    <style>
        input::-webkit-outer-spin-button,
        input::-webkit-inner-spin-button {
            -webkit-appearance: none;
        }
    </style>
</head>
<body class="container">
<?php require_once "Nav.php"; ?>
<div class="main">
    <?php include_once "menu.php"; ?>
    <div class="pr inlb bd col-xs-10">
        <table class="table table-striped">
            <caption>
                奖品管理
                <a href="#" onclick="addPrize()" style="font-size: 16px;border: 0">添加奖品</a>
            </caption>
            <tr>
                <th>名称</th>
                <th>消费</th>
                <th>备注</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            <?php

            for($i=0;$i<count($arr);++$i){
            ?>
            <tr>
                <td><?php echo $arr[$i]["name"]; ?></td>
                <td><?php echo $arr[$i]["expend"]; ?></td>
                <td><?php echo $arr[$i]["remark"]; ?></td>
                <td><?php echo $arr[$i]["status"]; ?></td>
                <td><a class="btn btn-primary" href="#" onclick="edt(<?php echo $arr[$i]["id"]; ?>)" ">编辑</a></td>
            </tr>
            <?php } ?>
        </table>

    </div>
</div>
<div id="dlg" class="modal fade">
    <div class="modal-dialog ">
        <div class="modal-content">
            <div class="modal-header">
                <div id="tt" class="modal-title">奖品编辑</div>
            </div>
            <div class="modal-body">
                <div class="form-horizontal">
                    <div class="form-group">
                        <input type="text" class="form-control" id="id" style="display: none">
                        <label for="name" class="col-xs-4 control-label">名称</label>
                        <div class="col-xs-8">
                            <input type="text" class="form-control" id="name">

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="expend" class="col-xs-4 control-label">要求消费</label>
                        <div class="col-xs-8">
                            <input type="number" min="0" class="form-control" id="expend">

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="remark" class="col-xs-4 control-label">备注</label>
                        <div class="col-xs-8">
                            <input type="text" class="form-control" id="remark">

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="status"  class="col-xs-4 control-label">状态</label>
                        <div class="col-xs-8">
                            <select name="" class="form-control" id="status">
                                <option value="正常">允许兑换</option>
                                <option value="删除">禁止兑换</option>
                            </select>

                        </div>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button class="btn btn-primary" data-dismiss="modal" onclick="chage()">确定</button>
                <button class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>

    </div>

</div>
<div id="msg" class="modal fade">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <div class="modal-title">提示</div>
            </div>
            <div class="modal-body">
                <div id="content"></div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal" onclick="reload()">确定</button>

            </div>
        </div>
    </div>
</div>
<script>
    function addPrize(){
        $("#id").val("")
        $("#name").val("")
        $("#expend").val("")
        $("#remark").val("")
        $("#status").val("正常")
        $("#dlg").modal("show")
    }
    function edt(id){
        $.post("getMessage.php",{getPrizeInfo:id},function(o){
            var js=JSON.parse(o);
            console.log(js.name)
            $("#id").val(js.id)
            $("#name").val(js.name)
            $("#expend").val(js.expend)
            $("#remark").val(js.remark)
            $("#status").val(js.status)
            $("#dlg").modal("show")
        })
    }
    function chage(){
        var id=$("#id").val()
        var name=$("#name").val()
        var expend=$("#expend").val()
        var remark=$("#remark").val()
        var status=$("#status").val()
        $.post("getMessage.php",{chge:id,name:name,expend:expend,remark:remark,status:status},function(o){
            $("#content").text(o)
            $("#msg").modal("show")
        })
    }
    function reload(){
        location.reload(true)
    }
    $(function(){
        $("td:contains(删除)").css("color","red");
    })
</script>
</body>
</html>
